Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed checkPathAgainstBase modifying basePaths unintentionally. #60

Merged
merged 2 commits into from
Mar 26, 2024

Conversation

k1LoW
Copy link
Contributor

@k1LoW k1LoW commented Mar 19, 2024

Hi there. Thank you for GREAT pkgs!

I fixed a problem where checkPathAgainstBase was unintentionally changing the basePath.
Also added a test that was panicky before the fix.

$ go test ./paths/... -run TestNewValidator_FindPathMissingWithBaseURLInServer
--- FAIL: TestNewValidator_FindPathMissingWithBaseURLInServer (0.00s)
panic: runtime error: index out of range [-1] [recovered]
        panic: runtime error: index out of range [-1]

goroutine 19 [running]:
testing.tRunner.func1.2({0x100ff8840, 0x140000181e0})
        /Users/k1low/sdk/go1.22.1/src/testing/testing.go:1631 +0x1c4
testing.tRunner.func1()
        /Users/k1low/sdk/go1.22.1/src/testing/testing.go:1634 +0x33c
panic({0x100ff8840?, 0x140000181e0?})
        /Users/k1low/sdk/go1.22.1/src/runtime/panic.go:770 +0x124
github.com/pb33f/libopenapi-validator/paths.checkPathAgainstBase({0x140001cfad1, 0x5}, {0x100e467a0, 0x8}, {0x1400002a0f0, 0x1, 0x14000010140?})
        /Users/k1low/src/github.com/pb33f/libopenapi-validator/paths/paths.go:227 +0x180
github.com/pb33f/libopenapi-validator/paths.comparePaths({0x140000782b0?, 0x1, 0x140001cfad0?}, {0x1400002a110, 0x1, 0x1}, {0x1400002a0f0, 0x1, 0x1})
        /Users/k1low/src/github.com/pb33f/libopenapi-validator/paths/paths.go:261 +0x1f0
github.com/pb33f/libopenapi-validator/paths.FindPath(0x14000000120, 0x14000394000)
        /Users/k1low/src/github.com/pb33f/libopenapi-validator/paths/paths.go:66 +0x270
github.com/pb33f/libopenapi-validator/paths.TestNewValidator_FindPathMissingWithBaseURLInServer(0x140001d0b60)
        /Users/k1low/src/github.com/pb33f/libopenapi-validator/paths/paths_test.go:657 +0xd0
testing.tRunner(0x140001d0b60, 0x101066d18)
        /Users/k1low/sdk/go1.22.1/src/testing/testing.go:1689 +0xec
created by testing.(*T).Run in goroutine 1
        /Users/k1low/sdk/go1.22.1/src/testing/testing.go:1742 +0x318
FAIL    github.com/pb33f/libopenapi-validator/paths     0.200s
FAIL

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.96%. Comparing base (f866c7b) to head (d929361).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #60   +/-   ##
=======================================
  Coverage   98.96%   98.96%           
=======================================
  Files          19       19           
  Lines        1156     1156           
=======================================
  Hits         1144     1144           
  Misses         12       12           
Flag Coverage Δ
unittests 98.96% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@daveshanley daveshanley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you for your contribution!

@daveshanley daveshanley merged commit 29ed98d into pb33f:main Mar 26, 2024
1 check passed
@k1LoW k1LoW deleted the fix-path-missing-with-panic branch March 26, 2024 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants